Skip to content

docs: add doc.go and rewrite exported godoc (#11)#20

Merged
millerjp merged 1 commit into
mainfrom
docs/doc-go-godoc
Apr 20, 2026
Merged

docs: add doc.go and rewrite exported godoc (#11)#20
millerjp merged 1 commit into
mainfrom
docs/doc-go-godoc

Conversation

@millerjp

Copy link
Copy Markdown

Summary

Moves package-level documentation into a dedicated doc.go and rewrites the godoc on every exported symbol in syncmap.go. The inline placeholder package comment added in #8 (solely to satisfy revive.package-comments) is removed.

Closes #11.

doc.go covers

  • Overview — what syncmap is, why it exists, assertion-free call sites.
  • Relationship to sync.Map — thin typed wrapper, API parity, same concurrency guarantees.
  • When to use SyncMap vs sync.Map vs map + sync.RWMutex — with guidance bullets.
  • Thread safety — inherited from sync.Map.
  • Zero value — usable, must not be copied after first use.
  • Quick Start — compiles mentally, uses tab-indented code block per godoc contract.

Per-symbol godoc rewrites (syncmap.go)

Every exported symbol now starts with its name and matches or improves on sync.Map's stdlib prose:

  • Len, Map, Keys, Items — each explicitly documents O(n) cost and "point-in-time approximation" under concurrent mutation.
  • LoadAndDelete — explicitly documents the typed-zero-value-on-miss contract (was returning nil/untyped pre-Go-generics wording).
  • Range — preserves stdlib sync.Map Range snapshot wording so readers familiar with stdlib recognise it.

Local validation

$ make check
… (all 14 gates pass)
coverage: 100.0% of statements
No vulnerabilities found.

$ go doc github.com/axonops/syncmap
Package syncmap provides a type-safe, generic wrapper around sync.Map.
… [full overview rendered]

$ for s in Len Map Keys Items; do go doc github.com/axonops/syncmap $s | grep 'O(n)'; done
    It runs in O(n) time by traversing the map with Range.
    in O(n) time.
    call. It runs in O(n) time.
    call. It runs in O(n) time.

$ go doc github.com/axonops/syncmap LoadAndDelete | grep 'zero value'
    was not present, value is the zero value of V.

Agent gates

  • Plan — execution plan for single-commit docs-only PR.
  • docs-writer (pre-code) — produced the draft content.
  • code-reviewer — approved; zero behaviour change confirmed (diff is pure comment + new file).
  • docs-writer (post-code) — PASS on all eight doc-standard criteria.
  • go-quality — 14/14 green.
  • commit-message-reviewer — PASS.

Out of scope

Test plan

  • CI green end-to-end (all guards, lint, tests, build matrix, security, release-check)
  • Coverage remains 100%
  • No regression on any quality gate

Move the package-level documentation into a dedicated doc.go,
covering relationship to sync.Map, when-to-use guidance, thread
safety, zero-value usability, and a quick-start example. Remove
the inline placeholder package comment that landed in #8 purely to
satisfy revive.package-comments.

Rewrite the godoc on every exported symbol (SyncMap, Load, Store,
LoadOrStore, LoadAndDelete, Delete, Range, Len, Map, Keys, Items)
to match or improve on sync.Map's stdlib prose. Len, Map, Keys and
Items now explicitly call out their O(n) cost and point-in-time
approximation under concurrent mutation; LoadAndDelete now states
the typed-zero-value-on-miss contract.

No behaviour change. No signature change. Coverage unchanged at
100%.
@millerjp millerjp merged commit 8ec4503 into main Apr 20, 2026
13 checks passed
@millerjp millerjp deleted the docs/doc-go-godoc branch April 20, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add doc.go and rewrite godoc on every exported symbol

1 participant